// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import './assets/css/comm.css'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/css/rest.scss'
import axios from 'axios'

Vue.config.productionTip = false
Vue.use(ElementUI)
// var api = process.env.API_ROOT
axios.defaults.baseURL = process.env.API_ROOT
axios.defaults.withCredentials = true
Vue.prototype.$http = axios
const downloadUrl = url => {
  let iframe = document.createElement('iframe')
  iframe.style.display = 'none'
  iframe.src = url
  iframe.onload = function () {
    document.body.removeChild(iframe)
  }
  document.body.appendChild(iframe)
}
axios.interceptors.response.use(res => {

  
  // return res
  // 处理excel文件
  if (res.headers['content-type'] === 'application/pdf') {
    // downloadUrl(res.request.responseURL)
    window.open(res.request.responseURL)
    // daishuaiqing
    return
  } else {
    return res
  }

}, error => {
  // Do something with response error
  return Promise.reject(error.response.data || error.message)
})

// Vue.component(CPdf.name, CPdf)
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
